<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>07-改变事件</title>
    <script>
        window.onload = function () {
            // 获取对象
          let useEle = document.getElementById("uName");
          useEle.onchange = function () {
            console.log(useEle.value)
          }
          // 下拉菜单对象
          let cityEle = document.getElementById("city");
          cityEle.onchange = function () {
            console.log(cityEle.value)
          }
        }
    </script>
</head>
<body>
<input type="text" name="username" id="uName" placeholder="请输入用户名：">

<select name="city" id="city">
  <option value="1">北京</option>
  <option value="2">上海</option>
  <option value="3">广东</option>
  <option value="4">深圳</option>
</select>
</body>
</html>